package com.pojo;

import java.util.List;

public class PageBean<T> {
    private List<T> data;//数据库查询的数据
    private int count;//总共有多少条数据

    private int current;//当前页
    private int size;//每页显示的条数

    private int first;//第一页
    private int previous;//上一页
    private int next;//下一页
    private int total;//总页数

    public PageBean() {
    }

    public PageBean(List<T> data, int count, int current, int size) {
        this.data = data;
        this.count = count;
        this.current = current;
        this.size = size;
    }

    /**
     * 获取
     * @return data
     */
    public List<T> getData() {
        return data;
    }

    /**
     * 设置
     * @param data
     */
    public void setData(List<T> data) {
        this.data = data;
    }

    /**
     * 获取
     * @return count
     */
    public int getCount() {
        return count;
    }

    /**
     * 设置
     * @param count
     */
    public void setCount(int count) {
        this.count = count;
    }

    /**
     * 获取
     * @return current
     */
    public int getCurrent() {
        return current;
    }

    /**
     * 设置
     * @param current
     */
    public void setCurrent(int current) {
        this.current = current;
    }

    /**
     * 获取
     * @return size
     */
    public int getSize() {
        return size;
    }

    /**
     * 设置
     * @param size
     */
    public void setSize(int size) {
        this.size = size;
    }

    /**
     * 获取
     * @return first
     */
    public int getFirst() {
        return 1;
    }

    /**
     * 设置
     * @param first
     */
    public void setFirst(int first) {
        this.first = first;
    }

    /**
     * 获取
     * @return previous
     */
    public int getPrevious() {
        return this.getCount()>1?this.getCount()-1:1;
    }

    /**
     * 设置
     * @param previous
     */
    public void setPrevious(int previous) {
        this.previous = previous;
    }

    /**
     * 获取
     * @return next
     */
    public int getNext() {
        return this.getCurrent()<this.getTotal()?this.getCurrent()+1:this.getTotal();
    }

    /**
     * 设置
     * @param next
     */
    public void setNext(int next) {
        this.next = next;
    }

    /**
     * 获取
     * @return total
     */
    public int getTotal() {
        return this.getCount()%this.getSize()>0?this.getCount()/this.getSize()+1:this.getCount()/this.getSize();
    }

    /**
     * 设置
     * @param total
     */
    public void setTotal(int total) {
        this.total = total;
    }

    public String toString() {
        return "PageBean{data = " + getData() + ", count = " + getCount() + ", current = " + getCurrent() + ", size = " + getSize() + ", first = " + getFirst() + ", previous = " + getPrevious() + ", next = " + getNext() + ", total = " + getTotal() + "}";
    }
}
